package com.tedu.movie.controller;

import com.tedu.movie.pojo.Admin;
import com.tedu.movie.pojo.ServerResult;
import com.tedu.movie.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin
@RestController
public class AdminController {
    @Autowired
    AdminService adminService;
    @RequestMapping("/admin/login")
    public ServerResult login(Admin admin){
        Admin dbAdmin = adminService.login(admin);
        dbAdmin.setPassword("");
        if(ObjectUtils.isEmpty(dbAdmin)){
            return new ServerResult(1,"登录失败",null);
        }else{
            return new ServerResult(0,"登录成功",dbAdmin);}
    }
}
